// RealPlay Ltd  copyrights.
// This program is Open Source AsIs
// You may use it for all purposes, including commercial
// But!!!
// If you use any part of this code, you must state clearly
// both in your source file and in the Help|about of your program,
// that the origin program or code was built by RealPlay Ltd

// ***********************************************************************/
// *                                                                     */
// *        This unit holds a frame of color pallete of "Paint" Program  */
// *                                                                     */
// ***********************************************************************/

unit UPFrColor;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TFrColor = class(TFrame)
    Panel1: TPanel;
    Panel5: TPanel;
    Panel6: TPanel;
    Panel7: TPanel;
    Panel8: TPanel;
    Panel9: TPanel;
    Panel10: TPanel;
    Panel11: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Panel12: TPanel;
    Panel13: TPanel;
    Panel14: TPanel;
    Panel15: TPanel;
    Panel16: TPanel;
    Panel17: TPanel;
    Panel18: TPanel;
    Panel19: TPanel;
    Panel20: TPanel;
    Panel21: TPanel;
    Panel22: TPanel;
    Panel23: TPanel;
    Panel24: TPanel;
    Panel25: TPanel;
    Panel26: TPanel;
    Panel27: TPanel;
    Panel4: TPanel;
    Pc: TPanel;
    BC: TPanel;
    Cd: TColorDialog;
    procedure PcClick(Sender: TObject);
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BCClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses UPMain;
{$R *.dfm}
// *******************************************************

procedure TFrColor.PcClick(Sender: TObject);
begin
  Cd.Color := Pc.Color;
  if Cd.Execute then
  begin
    Pc.Color := Cd.Color;
    Fpaint.FWA.Im.Canvas.Pen.Color := Cd.Color;
  end;
end;
// *******************************************************

procedure TFrColor.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if ssleft in Shift then
  begin
    Pc.Color := TPanel(Sender).Color;
    Fpaint.FWA.Im.Canvas.Pen.Color := Pc.Color;
  end
  else if ssRight in Shift then
  begin
    BC.Color := TPanel(Sender).Color;
    Fpaint.FWA.Im.Canvas.Brush.Color := BC.Color;
  end;
end;
// *******************************************************

procedure TFrColor.BCClick(Sender: TObject);
begin
  Cd.Color := BC.Color;
  if Cd.Execute then
    BC.Color := Cd.Color;
  Fpaint.FWA.Im.Canvas.Brush.Color := BC.Color;
end;

end.
